#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;

bool check(ll x)
{
	if(x<2)
		return false;
	for(int i=2;i<=sqrt(x);i++)
	{
		if(x%i==0)
			return false;
	}
	return true;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		ll a,b;
		cin>>a>>b;
		
		if(check(a*b))
		{
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}
